#ifndef WIDGET_H
#define WIDGET_H

#include "badminton.h"
#include <QWidget>
#include <QWidget>
#include<QGraphicsView>
#include<QGraphicsScene>
#include<QGraphicsPixmapItem>
#include<QPushButton>
#include<QGraphicsTextItem>
#include <player1.h>
#include <player2.h>
#include <QObject>
#include<QKeyEvent>
#include<QTimer>

QT_BEGIN_NAMESPACE
namespace Ui {
class Widget;
}
QT_END_NAMESPACE

class Widget : public QWidget
{
    Q_OBJECT
public:
    Widget(QWidget *parent = nullptr);
    ~Widget();

    void keyPressEvent(QKeyEvent *event);
    void keyReleaseEvent(QKeyEvent *event);

    QGraphicsView m_View;
    QGraphicsScene m_Scene1;//开始场景
    QGraphicsScene m_Scene2;//游戏场景
    QGraphicsPixmapItem m_BackGround1;//开始背景
    QGraphicsPixmapItem m_BackGround2;//游戏背景
    QGraphicsTextItem* m_counterText;
    QPushButton* Startbtn;//开始按钮
    Player1* player1;
    Player2* player2;
    Badminton* badminton;
    QTimer* GameTimer;//羽毛球计时器
    bool Player1S;
    bool Player2S;
    bool BadmintonIsServed;
    int player1Total;
    int player2Total;
    void handleMovement();
    // 在Widget类中添加成员变量
private:
    QSet<int> pressedKeys; // 记录当前按下的键

public slots:
    void InitGame();
    void IncreaseScore(int value1,int value2);
    void badmintonLanded();  // 新增羽毛球落地槽函数

private:
    Ui::Widget *ui;


};
#endif // WIDGET_H
